package com.example.model.vo;

import lombok.Data;

import java.util.List;

/**
 * 分页结果包装类
 */
@Data
public class PageResult<T> {
    
    private Long total;
    
    private Integer totalPages;
    
    private Integer currentPage;
    
    private List<T> items;
    
    public static <T> PageResult<T> of(List<T> items, Long total, Integer currentPage, Integer pageSize) {
        PageResult<T> result = new PageResult<>();
        result.setItems(items);
        result.setTotal(total);
        result.setCurrentPage(currentPage);
        
        // 计算总页数
        int totalPages = (int) Math.ceil((double) total / pageSize);
        result.setTotalPages(totalPages);
        
        return result;
    }
} 